<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2018/4/30
 * Time: 11:22
 */
namespace app\doctor\controller;

use app\common\model\Base;

class Caseinfo extends Base{

    public function index(){
        $this->selectAllInfo();
    }
    /**
     * 查询账号和密码是否匹配
     * @param str $tel 账号
     * @param str $passd 密码
     */
    function selectAllInfo() {
        $sql = "SELECT * FROM doctor_case";
        $result = $this->mysql->selectSQLAll($sql);
        if (is_array($result)) {
            $this->getAllInfo($result);
        } else {
            echo echoJson(0, "暂无记录!");
        }
    }

    /**
     * 得到用户信息并输出
     * @param arr $row 查询到的用户信息
     * @param type $tel 账号
     */
    function getAllInfo($result) {
        $Info = array();
        foreach ($result as $row) {
            isset($row["case_id"]) ? $case_id = $row["case_id"] : $case_id = null;
            isset($row["name"]) ? $name = $row["name"] : $name = null;
            isset($row["writer_head_portrait"]) ? $writer_head_portrait = $row["writer_head_portrait"] : $writer_head_portrait = null;
            isset($row["doctor_name"]) ? $doctor_name = $row["doctor_name"] : $doctor_name = null;
            isset($row["keyword"]) ? $keyword = $row["keyword"] : $keyword = null;
            isset($row["date"]) ? $date = $row["date"] : $date = null;
            isset($row["patient_head_portrait"]) ? $patient_head_portrait = $row["patient_head_portrait"] : $patient_head_portrait = null;
            isset($row["image"]) ? $image = json_decode($row["image"], true) : $image = null;
            isset($row["intro"]) ? $intro = $row["intro"] : $intro = null;
            isset($row["diagnose"]) ? $diagnose = $row["diagnose"] : $diagnose = null;
            isset($row["cure"]) ? $cure = $row["cure"] : $cure = null;
            $Info[] = array("case_id" => $case_id, "name" => $name, "writer_head_portrait" => $writer_head_portrait, "doctor_name" => $doctor_name,
                "keyword" => $keyword, "date" => $date, "patient_head_portrait" => $patient_head_portrait, "image" => $image,
                "intro" => $intro, "diagnose" => $diagnose, "cure" => $cure);
        }
        echo echoJson(1, $Info);
    }
}